﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using InsertIntoDataBase;
using OnlineVideos.Entities;
using Common.Library;
using OnlineVideos.UI;
using System.Threading.Tasks;

namespace OnlineMovies.Views
{
    public partial class AddExtras : PhoneApplicationPage
    {
        public AddExtras()
        {
            InitializeComponent();
        }
        private void imgTitle_MouseEnter(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            NavigationService.Navigate(NavigationHelper.MainPanoramaPage);
        }
        private void btnsave_Click_1(object sender, EventArgs e)
        {
            int matchid=AppSettings.ShowUniqueID;
            MatchExtras extras = Task.Run(async () => await Constants.connection.Table<MatchExtras>().Where(i => i.MatchID == matchid).FirstOrDefaultAsync()).Result;
            extras.TeamAExtras = tbxteamAextras.Text;
            extras.TeamBExtras = tbxteamBextras.Text;
            extras.TeamATotal = tbxteamAtotal.Text;
            extras.TeamBTotal = tbxteamBtotal.Text;
            extras.TeamResult = tbxteamresult.Text;
           Task.Run(async()=>await Constants.connection.UpdateAsync(extras));
            //InsertData<MatchExtras> insert = new InsertData<MatchExtras>();
            //insert.ParameterList = new MatchExtras();
            //insert.ParameterList.MatchID = AppSettings.ShowUniqueID;
            //insert.ParameterList.TeamAInnings = AppSettings.TeamATitle;
            //insert.ParameterList.TeamBInnings = AppSettings.TeamBTitle;
            //insert.ParameterList.TeamAExtras = tbxteamAextras.Text;
            //insert.ParameterList.TeamBExtras = tbxteamBextras.Text;
            //insert.ParameterList.TeamATotal = tbxteamAtotal.Text;
            //insert.ParameterList.TeamBTotal = tbxteamBtotal.Text;
            //insert.ParameterList.TeamResult = tbxteamresult.Text;
            //insert.Insert();
        }
    }
}